<div class="content-box">
	<div class="content-box-header">
		<h3>Content box</h3>
		<ul class="content-box-tabs">
			<li><a href="#" class="default-tab">Table</a></li>
		</ul>
		<div class="clear"></div>
	</div>
	<div class="content-box-content">
		<div class="tab-content default-tab">
			<div class="notification attention png_bg"
				style="background-image: none;">
				<div>
					<?php $form = $this->beginWidget('CActiveForm', array(
								'id'=>'recommend-form',
								'htmlOptions'=>array('onsubmit'=>'return checkForm()')
					)); ?>
					小说ID：
					<?php echo $form->textField($model, 'book_id',array('id'=>'book_id', 'onkeyup'=>'showBookTitle()')); ?>
					<?php echo CHtml::submitButton('添加'); ?>
					<span id="book_title"></span>
					<?php $this->endWidget(); ?>
				</div>
			</div>
			<table>
				<thead>
					<tr>
						<th>ID</th>
						<th>标题</th>
						<th>作者</th>
						<th>状态</th>
						<th>票数</th>
						<th>类别</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
				<?php $this->renderPartial('_view',array('model'=>$model)); ?>
				</tbody>
			</table>
		</div>
	</div>
</div>

<script>
	function checkForm()
	{
		if($("#book_id").val() == "")
		{
			$("#book_title").text("小说ID不能为空！");
			return false;
		}else if($("#book_title").text() == "此ID号没有对应的小说")
		{
			return false;
		}
		return true;
	}
	function showBookTitle() {
		$.post('<?php echo Yii::app()->createUrl('admin/site/getBookTitle'); ?>', {
			book_id : $('#book_id').val()
		}, function(data) {
			if (data == '') {
				html = "此ID号没有对应的小说";
			} else {
				html = "标题：" + data;
			}
			$("#book_title").text(html);
		});
	}
</script>